{extend name="/fool" /}
{block name="css"}
<link rel="stylesheet" href="/css/admin/integral.css">
<style>
    #page{
        position: relative;
        display: inline-block;
        left:30%;
        margin-left:-50px;
        padding:50px 0;
    }#title th{
        width: 8vw;
        font-weight: 500;
        line-height: 50px;
        color: #000000;
     }
    #title td{
        text-align: center;
        color: #707070;
    }
    #mxk{
        display: none;
        padding:30px;
        border-radius: 10px;
        box-shadow: 0 0 5px 0 rgba(0,0,0,0.5);
        position: absolute;
        width:460px;
        left:50%;
        top:50%;
        margin-top: -100px;
        margin-left: -230px;
        z-index: 99;
        background: #fff;
    }
    #mxk ul{
        margin-top:20px;
    }
    #mxk li{
        text-align: center;
        margin: 5px 0 ;
        width:100px;
        float: left;
    }
    #jfjl{
        text-align: center;
        font-weight: 800;
        font-size: 20px;
        margin-bottom: 10px;
    }
    #titles{
        font-size: 18px;
        margin: 5px 0;
    }
    .gb{
        position: absolute;
        top:0;
        right: 0;
    }
</style>
{/block}
{block name="menu_content"}
<div id="mxk">
    <div style="position: relative;">
        <div id="jfjl">积分记录明细</div>
        <button style="height:25px;line-height: 25px;" type="button" class="gb layui-btn">关闭</button>
        <div id="titles">获得<span class="titles">产品代理积分</span></div>
        <div>消费<span class="product">手机产品</span><span class="money">3000</span>元</div>
        <div>获得<span class="jftitle">直推积分</span>:+<span class="jf">154</span></div>
        <div>
            <ul style="overflow: hidden;" class="uls">
            </ul>
        </div>
    </div>
</div>
<div style="margin: 50px 0 0 50px;">
    <button type="button" class="jbxx layui-btn layui-btn-primary">基本信息</button>
    <button type="button" class="qbjl layui-btn layui-btn-primary">钱包记录</button>
    <button type="button" class="jfjl layui-btn layui-btn-primary" style="border-color: #1989FA;color: #1989FA;">积分记录</button>
    <button type="button" class="tdcy layui-btn layui-btn-primary">团队成员</button>
</div>
<div>
    <table id="title" style="margin-left: 5vw;margin-top: 3vh;">
        <tr>
            <th>产品兑换积分</th>
            <th>公司证券</th>
            <th>贷款额度积分</th>
            <th>sto</th>
            <th>设备维养</th>
        </tr>
        <tr>
            <td>{$home['cpjf']}</td>
            <td>{$home['gsjf']}</td>
            <td>{$home['dkjf']}</td>
            <td>{$home['sto']}</td>
            <td>{$home['seb']}</td>
        </tr>
    </table>
</div>
<div id="one">
    <form class="layui-form" action="" method="post">
        <ul>
            <li>
                <div class="layui-input-inline">
                    <select name="source">
                        <option value="">类型</option>
                        <option value="1">产品代理积分</option>
                        <option value="2">兑换产品</option>
                        <option value="3">兑换贷款额度</option>
                    </select>
                </div>
                <div class="layui-input-inline">
                    <input type="text" name="time" class="layui-input" id="test1" placeholder="开始时间 至 结束时间">
                </div>
                <button type="Submit" class="layui-btn">筛选</button>
            </li>
        </ul>
    </form>
</div>
<div id="two">
    <table>
        <tr>
            <th>时间</th>
            <th>类型</th>
            <th>积分</th>
            <th class="last">明细</th>
        </tr>
        {if isset($list)}
        {foreach $list as $v}
        <tr class="list">
            <td>{$v.create_time}</td>
            <td>
                {if $v.source == 1}产品代理积分
                {elseif $v.source == 2}兑换产品
                {elseif $v.source == 3}兑换贷款额度
                {elseif $v.source == 4}
                {elseif $v.source == 5}
                {/if}
            </td>
            <td>{$v.num}</td>
            <td>
                <button sid="{$v.id}" type="button" class="viewbu layui-btn">查看</button>
            </td>
        </tr>
        {/foreach}
        {/if}
    </table>
    <div id="page">
        {if isset($list)}
        {$page|raw}
        {/if}
    </div>
</div>
<script>
    $(".gb").click(function(){
        $("#mxk").hide();
    })
    layui.use('form', function(){
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function(data){
            layer.msg(JSON.stringify(data.field));
            return false;
        });
    });
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#test1'
            ,type: 'month'
            ,range: '至'
            ,format: 'yyyy-MM'
        });
    });
    $(".viewbu").click(function(){
        $("#mxk").show();
        var id = $(this).attr('sid');
        $.post("{:url('views')}",{
            id
        },function(res){
            //1=>产品代理积分,2=>兑换产品,3=>兑换贷款额度,
            // 4=>产品代理平级积分,5=>产品代理互助积分,6=>商家权益积分,
            // 7=>服务中心权益积分,8=>租赁代理积分,9=>租赁代理平级积分,
            // 10=>租赁代理互助积分,11=>服务中心租赁积分,12=>直推商家代理,
            // 13=>直推合伙人,14=>下级商户租赁代理业绩分成,15=>会员权益积分,
            // 16=>代理权益积分
            if(res.source == 1){
                $("#mxk").find('.jftitle').html('产品代理积分');
                $(".titles").html('产品代理积分')
            }else if(res.source == 2){
                $("#mxk").find('.jftitle').html('兑换产品');
                $(".titles").html('兑换产品')
            }else if(res.source == 3){
                $("#mxk").find('.jftitle').html('兑换贷款额度');
                $(".titles").html('兑换贷款额度')
            }else if(res.source == 4){
                $("#mxk").find('.jftitle').html('产品代理平级积分');
                $(".titles").html('产品代理平级积分')
            }else if(res.source == 5){
                $("#mxk").find('.jftitle').html('产品代理互助积分');
                $(".titles").html('产品代理互助积分')
            }else if(res.source == 6){
                $("#mxk").find('.jftitle').html('商家权益积分');
                $(".titles").html('商家权益积分')
            }else if(res.source == 7){
                $("#mxk").find('.jftitle').html('服务中心权益积分');
                $(".titles").html('服务中心权益积分')
            }else if(res.source == 8){
                $("#mxk").find('.jftitle').html('租赁代理积分');
                $(".titles").html('租赁代理积分')
            }else if(res.source == 9){
                $("#mxk").find('.jftitle').html('租赁代理平级积分');
                $(".titles").html('租赁代理平级积分')
            }else if(res.source == 10){
                $("#mxk").find('.jftitle').html('租赁代理互助积分');
                $(".titles").html('租赁代理互助积分')
            }else if(res.source == 11){
                $("#mxk").find('.jftitle').html('服务中心租赁积分');
                $(".titles").html('服务中心租赁积分')
            }else if(res.source == 12){
                $("#mxk").find('.jftitle').html('直推商家代理');
                $(".titles").html('直推商家代理')
            }else if(res.source == 13){
                $("#mxk").find('.jftitle').html('直推合伙人');
                $(".titles").html('直推合伙人')
            }else if(res.source == 14){
                $("#mxk").find('.jftitle').html('下级商户租赁代理业绩分成');
                $(".titles").html('下级商户租赁代理业绩分成')
            }else if(res.source == 15){
                $("#mxk").find('.jftitle').html('会员权益积分');
                $(".titles").html('会员权益积分')
            }else if(res.source == 16){
                $("#mxk").find('.jftitle').html('代理权益积分');
                $(".titles").html('代理权益积分')
            }
            $("#mxk").find('.jf').html(res.num);
            $("#mxk").find('.product').html(res.order.name);
            $("#mxk").find('.money').html(res.order.money);
            var int = res.integraldetailed;
            console.log(int.length);
            if(int.length >= 0){
                $('.uls').html('');
            }
            //1=>产品兑换积分,2=>公司证券,3=>贷款额度积分,4=>sto,5=>设备维养,6=>税收积分
            var leng = int.length;
            $.each(int,function(k,v){
                if(v.status == 1){
                    var title= '产品兑换积分'
                }else if(v.status == 2){
                    var title= '公司证券'
                }else if(v.status == 3){
                    var title= '贷款额度积分'
                }else if(v.status == 4){
                    var title= 'sto'
                }else if(v.status == 5){
                    var title= '设备维养'
                }else if(v.status == 6){
                    var title= '税收积分'
                }
                var mhtml = $('.uls').html();
                var html = mhtml + "<li>"+
                    "<div class=\"title\">" + title + "</div>"+
                    "<div class=\"val\">" + v.num + "</div>"+
                    "</li>"
                $('.uls').html(html);
                if(k == leng-1){
                    var mhtml = $('.uls').html()
                    var html = mhtml + "<li style=\"clear: both;\"></li>"
                    $('.uls').html(html)
                }

            })
        },'json')
    })
    layui.use('laypage', function(){
        var laypage = layui.laypage;
        //执行一个laypage实例
        laypage.render({
            elem: 'page'
            ,count: "{$count}"
            ,curr:"{$curl}"
            ,last:"{$groups}"
            ,limit:"{$limit}"
            ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
            ,jump: function(obj,first){
                if(!first){
                    var url = "{:url('index',['id'=>5,'index'=>0])}" + '&page=' + obj.curr + '&limit=' + obj.limit + '&curr=' + obj.curr;
                    location.href = url;
                }
            }
        });
    });
    //用户基本信息
    $(".jbxx").click(function(){
        var url = "{:url('user/view')}" + '?battery_order=' + "{$id}"
        location.href = url;
    })
    //用户钱包记录
    $(".qbjl").click(function(){
        var url = "{:url('wallet/index')}" + '?battery_order=' + "{$id}"
        location.href = url;
    })
    //用户积分记录
    $(".jfjl").click(function(){
        var url = "{:url('integral/user')}" + '?battery_order=' + "{$id}"
        location.href = url;
    })
    //用户团队成员
    $(".tdcy").click(function(){
        var url = "{:url('user/team')}" + '?battery_order=' + "{$id}"
        location.href = url;
    })
</script>
{/block}